/*

如何使用相机？
image_picker 插件被常用于相机功能的使用。


https://pub-web.flutter-io.cn/packages/image_picker
 */


import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';

void main(){
  runApp(const MyApp());
}

class MyApp extends StatelessWidget{
  const MyApp({super.key});
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: '',
      home: Scaffold(
        appBar: AppBar(title: const Text('')),
        body: Center(
          child: ElevatedButton(
            onPressed: getLostData,
            child: Text('getLostData'),
          ),
        ),
      ),
    );
  }
}

Future<void> getLostData() async {
  final ImagePicker picker = ImagePicker();
  final LostDataResponse response = await picker.retrieveLostData();
  if (response.isEmpty) {
    print("== 获取文件为空");
    return;
  }
  final List<XFile>? files = response.files;
  if (files != null) {
    // _handleLostFiles(files);
    for(int k=0; k < files.length; k ++){
      print("== 文件名: ${files[k].name}");
    }
  } else {
    // _handleError(response.exception);
  }
}